interface IRouter {
    path: string,
    name: string,
    components: string & Object
}
export function buildRouter(router: Array<IRouter>, ensure: boolean = false): Array<Object> {
    if (router && router instanceof Array) {
        // if (ensure) {
        //     return router.map((item, index) => {
        //         let component=r => require.ensure([], () => r(require(item.components)), `chunk${index}`);
        //         return {
        //             path: item.path,
        //             name: item.name,
        //             component: typeof item.components === 'string' ? r => require.ensure([], () => r(require(item.components)), `chunk${index}`) : null
        //         }
        //     })
        // }
        return router.map(function (item) {
            return {
                path: item.path,
                name: item.name,
                component: Object.prototype.toString.call(item.components) === '[object Object]'||typeof item.components==='function' ? item.components : null
            };
        });
    }
    return [];
}
